package com.pocketsweet.service;
/**
 * 
 *//*
package com.pocketsweet.service;

import com.avos.avoscloud.AVGeoPoint;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.location.LocationClientOption.LocationMode;
import com.pocketsweet.MLApplication;

*//**
 * @author bobhu
 * 
 *//*
public class GeoService {
	private String mAddr;
	private double mLontitude;
	private double mLatitude;
	private boolean isLocated = false;

	private LocationClient client;
	private LocationClientOption option;

	private static GeoService _instance = null;

	private GeoService() {
		if (client == null || option == null) {
			initLocationService();
			getLocation();
		}
	}

	private void initLocationService() {
		client = new LocationClient(MLApplication.getContext());
		option = new LocationClientOption();
		option.setOpenGps(false);
		option.setCoorType("bd09ll");
		option.setProdName("molian");
		option.setLocationMode(LocationMode.Battery_Saving);
		option.setIsNeedAddress(true);// 返回的定位结果包含地址信息
		option.setScanSpan(0);
		client.setLocOption(option);
		client.registerLocationListener(new BDLocationListener() {
			@Override
			public void onReceiveLocation(BDLocation location) {
				if (location == null)
					return;
				
				mLatitude = location.getLatitude();
				mLontitude = location.getLongitude();
				mAddr = "" + location.getAddrStr();
				client.stop();
				isLocated = true;
			}
		});
		client.start();
	}

	public static GeoService getInstance() {
		if (_instance == null) {
			_instance = new GeoService();
		}
		return _instance;
	}

	*//**
	 * 获得当前的位置
	 * 
	 * @return
	 *//*
	public AVGeoPoint getCurrentLocation() {
		if (isLocated) {
			// return 上一次的地理位置
			return new AVGeoPoint(mLontitude, mLatitude);
		} else {
			getLocation();
			return null;
			//return new AVGeoPoint(mLontitude, mLatitude);
		}
	}

	*//**
	 * 返回当前用户所在地址
	 * 
	 * @return
	 *//*
	public String getCurrentPlaceName() {
		if (isLocated) {
			// return 上一次的地理位置
			return mAddr;
		} else {
			getLocation();
			return mAddr;
		}
	}

	private void getLocation() {		
		client.requestLocation();
	}
}
*/